package zmee.sso;

import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 用于获取resources/sso.properties中的配置参数
 * @author ncc
 *
 */
public class YSPLSsoParam {
	private static Log logger = LogFactory.getLog(YSPLSsoParam.class);
	
	private String clientId;//应用ID
	private String secret;//应用秘钥
	private String yyclientId;//应用ID
	private String yysecret;//应用秘钥
	private String authUrl;//认证地址
	private String accessUrl;//获取TOKEN地址
	private String userUrl;//获取用户信息地址
	private String callBackUrl;//回调地址
	private String plLoginUrl;//派拉登入地址
	
	public YSPLSsoParam(boolean newGet) {
		if(newGet) {
			setParam();
		}
	}
	
	private void setParam() {

		try {
			Properties properties = new Properties();
//			InputStream in = this.getClass().getResourceAsStream("/sso.properties");
			InputStream in = this.getClass().getClassLoader().getResourceAsStream("resources/sso.properties");//resources
			properties.load(in);
			setClientId(properties.getProperty("clientId"));
			setSecret(properties.getProperty("secret"));
			setyyclientId(properties.getProperty("yyclientId"));
			setyySecret(properties.getProperty("yysecret"));
			setAuthUrl(properties.getProperty("authUrl"));
			setAccessUrl(properties.getProperty("accessUrl"));
			setUserUrl(properties.getProperty("userUrl"));
			setCallBackUrl(properties.getProperty("callBackUrl"));
			setPlLoginUrl(properties.getProperty("plLoginUrl"));
			logger.info("kd.bos.exam.utils.PLSsoParam-派拉单点配置信息："+toString());
		} catch (IOException e) {
			e.printStackTrace();
			logger.error("kd.bos.exam.utils.PLSsoParam.setParam():"+e.toString());
		}
	}
	
	public String getClientId() {
		return clientId;
	}
	public void setClientId(String clientId) {
		this.clientId = clientId;
	}
	public String getSecret() {
		return secret;
	}
	public void setSecret(String secret) {
		this.secret = secret;
	}
	public String getyyclientId() {
		return yyclientId;
	}
	public void setyyclientId(String yyclientId) {
		this.yyclientId = yyclientId;
	}
	public String getyySecret() {
		return yysecret;
	}
	public void setyySecret(String yysecret) {
		this.yysecret = yysecret;
	}
	public String getAuthUrl() {
		return authUrl;
	}
	public void setAuthUrl(String authUrl) {
		this.authUrl = authUrl;
	}
	public String getAccessUrl() {
		return accessUrl;
	}
	public void setAccessUrl(String accessUrl) {
		this.accessUrl = accessUrl;
	}
	public String getUserUrl() {
		return userUrl;
	}
	public void setUserUrl(String userUrl) {
		this.userUrl = userUrl;
	}
	public String getCallBackUrl() {
		return callBackUrl;
	}
	public void setCallBackUrl(String callBackUrl) {
		this.callBackUrl = callBackUrl;
	}
	public String getPlLoginUrl() {
		return plLoginUrl;
	}
	public void setPlLoginUrl(String plLoginUrl) {
		this.plLoginUrl = plLoginUrl;
	}

	@Override
	public String toString() {
		return "PLSsoParam [yyclientId=" + yyclientId +", yysecret=" + yysecret + "clientId=" + clientId + ", secret=" + secret + ", authUrl=" + authUrl + ", accessUrl="
				+ accessUrl + ", userUrl=" + userUrl + ", callBackUrl=" + callBackUrl + ", plLoginUrl=" + plLoginUrl
				+ "]";
	}
}
